package com.scm.dao.impl.mysql;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.scm.bean.Opencheckinfo;
import com.scm.bean.Vehicle;
import com.scm.dao.base.ICheckBoxDao;

public class CheckBoxDao extends HibernateDaoSupport implements ICheckBoxDao {

	public int queryOpencheckinfo() {
		// TODO Auto-generated method stub
		SessionFactory sessionfactory=new Configuration().configure().buildSessionFactory();
		Session session=sessionfactory.openSession();
		Query query=session.createQuery("SELECT COUNT(vinNumber) FROM Vehicle");
		int count=Integer.parseInt(query.uniqueResult().toString());
		return count;
	}

	public List<Vehicle> queryopencheckinfo(int start) {
		// TODO Auto-generated method stub
		SessionFactory sessionfactory=new Configuration().configure().buildSessionFactory();
		Session session=sessionfactory.openSession();
		Query query=session.createQuery("from Vehicle where vinResult=1");
		query.setFirstResult(start);
		query.setMaxResults(15);
		return query.list();
	}

}
